import { User } from '@/business/user/entities/user.entity';
import { CommonEntity } from '@/common/common-entity';
import { ApiPropertyOptional } from '@nestjs/swagger';
import { Entity, Column, OneToOne } from 'typeorm';

@Entity('attachement')
export class Attachement extends CommonEntity {

  @ApiPropertyOptional({description: '文件原始名称'})
  @Column({type: 'varchar', comment: '文件原始名称', length: 255})
  name: string;

  @ApiPropertyOptional({description: '文件名称'})
  @Column({type: 'varchar', comment: '文件名称', length: 255})
  filename: string;

  @ApiPropertyOptional({ description: 'url' })
  @Column({ type: 'varchar', nullable: true, comment: 'url', length: 128 })
  url: string | null;

  @ApiPropertyOptional({ description: '文件大小' })
  @Column({ type: 'int', default: 0, nullable: true, comment: '文件大小' })
  size: number | null;

  @ApiPropertyOptional({ description: '文件类型' })
  @Column({ type: 'varchar', nullable: true, comment: '文件类型', length: 255 })
  mimetype: string | null;

  @ApiPropertyOptional({ description: '关联数据状态；0 未使用；1 正在使用' })
  @Column({
    type: 'tinyint',
    width: 1,
    default: 1,
    nullable: true,
    comment: '关联数据状态；0 未使用；1 正在使用'
  })
  status: number | null;

  // @ApiPropertyOptional({ type: Manager })
  @OneToOne(() => User, (user) => user.avatar)
  user: User;
}
